import sys
sys.path.append("..")
from Config import config
import nni
import torch


def get_default_parameters():
    # 关键参数，包括要调参的参数
    params = \
        {
            # decareSample + lightGCN + bpr
            "device": torch.device('cuda:2' if torch.cuda.is_available() else "cpu"),
            "sample_style": "uij",    # uil: user-item-label, uij: user-posItem-NegItem
            "sample_way": "all_pos_random",    # [all_pos_random, user_decare]
            "dataset": 'yelp2018',  # [lastfm, gowalla, yelp2018, amazon-book]
            "model": 'lgn_sign',  # mf, lgn, lgn_hash, lgn_hash_tanh, lgn_fc_hash_tanh

            "loss": 'bpr',  # [bce, bpr, sauc_for_sample, sauc_for_user]
            "weight_decay": 0.0001,

            "is_use_early_stop": False,
            'batch_size': 1024,
            'lr': 0.001,
        }
    return params


if __name__ == "__main__":
    '''
    仅供nni测试使用
    '''
    from main import main
    try:
        # get parameters form tuner
        tuner_params = nni.get_next_parameter()
        config.update(get_default_parameters())
        config.update(tuner_params)
        # log_file_name = params["project_name"] + "_" + current_time + ".log"
        # logger = logCof(logger, "../log/", log_file_name)
        # logger.info(params)
        main(config)
    except Exception as exception:
        # logger.exception(exception)
        raise